package org.youyun56.gpsserver.db;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.youyun56.gpsserver.entity.City;

import com.j3.sql.GridUtils;

public class CityDao {
    private final static String findAll = "select id,name from city";

    public List<City> findAll() throws SQLException {
        GridUtils grid = new GridUtils();
        grid.init(findAll);
        List<City> citys = new ArrayList<City>();
        while (grid.next()) {
            City city = new City();
            city.setId(grid.getInt("id"));
            city.setName(grid.get("name"));
            citys.add(city);
        }
        return citys;
    }

}
